package com.situ.service.sal_chance;
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



import com.situ.dao.sal_chance.SalChanceDao;

import com.situ.entity.sal_chance.SalChance;
/**
 * SalChance的服务接口的实现类
 * 
 * @author 胡文 qq:986776
 *
 */
@Service
public class SalChanceServiceImpl implements SalChanceService {
	private final Logger LOG = LogManager.getLogger(this.getClass());

	@Autowired
	private SalChanceDao salChanceDao;

/**
* 查询....
*/
	@Override
	public List<SalChance> find(SalChance value) {

		List<SalChance> result = salChanceDao.selectSalChanceByObj(value);

		return result;
	}
    /**
* 根据id查询
*/
	@Override
	public SalChance findOne(Long id) {

		SalChance result = salChanceDao.selectSalChanceById(id);

		return result;
	}

/**
* 添加不为空
*/
	@Override
	public SalChance saveNotNull(SalChance value) {
		if (value == null) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行将SalChance中属性值不为null的数据保存到数据库-->失败:对象不能为空");
			}
			return value;
		}
		if(value.getChc_cust_name() == null || value.getChc_title() == null || value.getChc_desc() == null || value.getChc_create_id() == null || value.getChc_create_by() == null  ){
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行将SalChance中属性值不为null的数据保存到数据库-->失败:存在不能为空的空值");
			}
			return value;
		}
		int result = salChanceDao.insertNotNullSalChance(value);
		if (LOG.isDebugEnabled()) {
			LOG.debug("执行将SalChance中属性值不为null的数据保存到数据库-->结果:", result);
		}
		return value;
	}
	@Override
    /**
* 修改不为空
*/
	public int updateNotNullById(SalChance value) {
		if (value == null) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行通过SalChance的id更新SalChance中属性不为null的数据-->失败:对象为null");
			}
			return 0;
		}
		int result = salChanceDao.updateNotNullSalChanceById(value);
		if (LOG.isDebugEnabled()) {
			LOG.debug("执行通过SalChance的id更新SalChance中属性不为null的数据-->结果:", result);
		}
		return result;
	}
    /**
* 删除
*/
	@Override
	public int deleteById(Long id) {
		if (id == null) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行通过SalChance的id删除SalChance-->失败:id不能为空");
			}
			return 0;
		}
		int result = salChanceDao.deleteSalChanceById(id);
		if (LOG.isDebugEnabled()) {
			LOG.debug("执行通过SalChance的id删除SalChance-->结果:", result);
		}
		return result;
	}

    @Override
    public List<SalChance> find1(SalChance chance) {
        List<SalChance> result = salChanceDao.selectSalChanceByObj2(chance);
        return result;
    }


}